/*
 * Copyright (c) 2006-2021, RT-Thread Development Team
 *
 * SPDX-License-Identifier: Apache-2.0
 *
 * Change Logs:
 * Date           Author       Notes
 */

#include <rthw.h>
#include <rtconfig.h>
#include "gd32f20x.h"

#ifndef RT_USING_FINSH
#error Please uncomment the line <#include "finsh_config.h"> in the rtconfig.h 
#endif

#ifdef RT_USING_FINSH

#define UART_CONSOLE         USART0
RT_WEAK char rt_hw_console_getchar(void)
{
    int ch = -1;

    if (usart_flag_get(UART_CONSOLE, USART_FLAG_RBNE) != RESET)
    {
        ch = usart_data_receive(UART_CONSOLE);
    }

    return ch;
}

#endif /* RT_USING_FINSH */

